package net.hzlj.platform.enterprise.widght;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import net.hzlj.rl.zhangjiajie.R;

public class LoadingDialog extends Dialog {

	private TextView mTextView;
	private TextView mOutTextView;

	private boolean mIsOut = true;

	public LoadingDialog(Context context) {
		super(context, R.style.LoadingDialog);

		setContentView(R.layout.ui_dialog_loading);
		mTextView = (TextView) findViewById(android.R.id.message);
		mOutTextView = (TextView) findViewById(R.id.out);
		mOutTextView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
		//setCancelable(false);
		setCanceledOnTouchOutside(false);
	}

	@Override
	public void show() {
		super.show();
	}

	@Override
	public void dismiss() {
		super.dismiss();
	}

	public void show(String message,boolean isOut) {
		if (isShowing()) {
			dismiss();
		}
		if (mTextView != null) {
			mTextView.setText(message);
			mTextView.setVisibility(View.VISIBLE);
		}
		if (isOut){
			mOutTextView.setVisibility(View.VISIBLE);
		}else{
			mOutTextView.setVisibility(View.GONE);
		}
		super.show();
	}

	public void show(String message) {
		show(message,false);
	}


	/* (non-Javadoc)
	 * @see android.app.Dialog#onBackPressed()
	 */
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		Log.i("Loading", "---002-->onBackPressed");
		dismiss();
	}

}
